package order

import (
	//"bee/models"
	//"github.com/go-resty/resty/v2"
	//"net/http"
	//"strconv"
	//"strings"
)

type BaseInfo struct {
	OrderType    string `json:"orderType"`
	PurchaserID  string `json:"purchaserId"`
	ServiceType  string `json:"serviceType"`
	SalesChannel string `json:"salesChannel"`
	TerminalType string `json:"terminalType"`
}

type OrdinaryProduct struct {
	ProductID        string  `json:"productId"`
	ProductVersionID string  `json:"productVersionId"`
	StandardPrice    float64 `json:"standardPrice"`
	MinimumPrice     float64 `json:"minimumPrice"`
	SellingCount     int     `json:"sellingCount"`
	SellingAmount    string `json:"sellingAmount"`
}

type ProductInfo struct {
	OrdinaryProductList []OrdinaryProduct `json:"ordinaryProductList"`
	ReductionReason string `json:"reductionReason"`
}

type ContactInfo struct {
	ContactName string `json:"contactName"`
	Phone       string `json:"phone"`
	Gender      string `json:"gender"`
	Role        string `json:"role"`
}

type OrderRemark struct {
	SignerID     string `json:"signerId"`
	OperatorType string `json:"operatorType"`
	OperatorID   string `json:"operatorId"`
}

type AccountDeduct struct {
	AccountID       int    `json:"accountId"`
	AccountType     string `json:"accountType"`
	TradeAmount     int    `json:"tradeAmount"`
	AvailableAmount int    `json:"availableAmount"`
}

type BalanceDeductInfo struct {
	CustomerIdentityID  int           `json:"customerIdentityId"`
	CouponDeductAmount  int           `json:"couponDeductAmount"`
	AccountDeductAmount int           `json:"accountDeductAmount"`
	InvoiceAmount       int           `json:"invoiceAmount"`
	CouponDeductList    []interface{} `json:"couponDeductList"`
	AccountDeductList   []AccountDeduct `json:"accountDeductList"`
}

type PayInfo struct {
	PaymentWay        string `json:"paymentWay"`
	BalanceDeductInfo  `json:"balanceDeductInfo"`
}

type OrdinaryOrder struct {
	BaseInfo  `json:"baseInfo"`
	ProductInfo  `json:"productInfo"`
	InvoiceBeforePaid string `json:"invoiceBeforePaid"`
	InvoiceInfo `json:"invoiceInfo"`
	DeliveryInfo  `json:"deliveryInfo"`
	ContactInfo  `json:"contactInfo"`
	OrderRemark  `json:"orderRemark"`
	PayInfo `json:"payInfo"`
}

func SetOrdinaryOrder(customerId string, customerIdentityId string, accountId int, appNamespace string) (string, error) {
	return "", nil
	//appName := "opc"
	//uri := "/api/otcpro/v1/order/ordinaryOrder/save"
	//
	//appId, appErr:= models.GetAppIdByName(appName)
	//if appErr != nil {
	//	return "", appErr
	//}
	//
	//appEnv, envErr:= models.GetAppEnvInfo(appId, appNamespace)
	//if envErr != nil {
	//	return "", envErr
	//}
	//
	//host := appEnv.AppDomain
	//if !strings.HasPrefix(host, "http://") {
	//	host = "http://" + host
	//}
	//
	//baseInfo := BaseInfo{
	//	OrderType:    "0",
	//	PurchaserID:  customerId,
	//	ServiceType:  "01",
	//	SalesChannel: "50",
	//	TerminalType: "1",
	//}
	//
	//var ordinaryProductList []OrdinaryProduct
	//
	//ordinaryProductA := OrdinaryProduct{
	//	ProductID:        "32575",
	//	ProductVersionID: "56121",
	//	StandardPrice:    0.1,
	//	MinimumPrice:     0.1,
	//	SellingCount:     1,
	//	SellingAmount:    "0.1",
	//}
	//
	//ordinaryProductB := OrdinaryProduct{
	//	ProductID:        "32574",
	//	ProductVersionID: "56173",
	//	StandardPrice:    11,
	//	MinimumPrice:     11,
	//	SellingCount:     1,
	//	SellingAmount:    "11",
	//}
	//
	//ordinaryProductC := OrdinaryProduct{
	//	ProductID:        "32573",
	//	ProductVersionID: "56148",
	//	StandardPrice:    6000,
	//	MinimumPrice:     6000,
	//	SellingCount:     1,
	//	SellingAmount:    "88.9",
	//}
	//
	//reductionReason := "bee自动造数"
	//
	//ordinaryProductList = append(ordinaryProductList, ordinaryProductA, ordinaryProductB, ordinaryProductC)
	//
	//productInfo := ProductInfo{
	//	OrdinaryProductList: ordinaryProductList,
	//	ReductionReason:     reductionReason,
	//}
	//
	//invoiceBeforePaid := "0"
	//
	//invoiceInfo := InvoiceInfo{
	//	InvoiceType:      "4",
	//	InvoiceTitleType: "2",
	//	Title:            "bee自动造数开票抬头",
	//}
	//
	//deliveryInfo := DeliveryInfo{
	//	ReceiverEmail:  "11@qq.com",
	//	ReceiverMobile: "13635534591",
	//}
	//
	//contactInfo := ContactInfo{
	//	ContactName: "河北-测试-1",
	//	Phone:       "",
	//	Gender:      "0",
	//	Role:        "",
	//}
	//
	//orderRemark := OrderRemark{
	//	SignerID:     "b763cad2fe2542018602d41fccc4ee39",
	//	OperatorType: "2",
	//	OperatorID:   "b763cad2fe2542018602d41fccc4ee39",
	//}
	//
	//var accountDeductList  []AccountDeduct
	//
	//accountDeductA := AccountDeduct{
	//	AccountID:       accountId,
	//	AccountType:     "CASH",
	//	TradeAmount:     100,
	//	AvailableAmount: 9900,
	//}
	//
	//accountDeductList = append(accountDeductList, accountDeductA)
	//IdentityId, _ := strconv.Atoi(customerIdentityId)
	//
	//balanceDeductInfo := BalanceDeductInfo{
	//	CustomerIdentityID: IdentityId,
	//	CouponDeductAmount:  0,
	//	AccountDeductAmount: 100,
	//	InvoiceAmount:       0,
	//	CouponDeductList:    nil,
	//	AccountDeductList:   accountDeductList,
	//}
	//
	//payInfo := PayInfo{
	//	PaymentWay:        "2",
	//	BalanceDeductInfo: balanceDeductInfo,
	//}
	//
	//order := OrdinaryOrder{
	//	BaseInfo:          baseInfo,
	//	ProductInfo:       productInfo,
	//	InvoiceBeforePaid: invoiceBeforePaid,
	//	InvoiceInfo:       invoiceInfo,
	//	DeliveryInfo:      deliveryInfo,
	//	ContactInfo:       contactInfo,
	//	OrderRemark:       orderRemark,
	//	PayInfo:           payInfo,
	//}
	//
	//ssoCookie := &http.Cookie{
	//	Name:       "sso-epctoken",
	//	Value:      appEnv.Token,
	//}
	//
	//headers := make(map[string]string)
	//headers["Content-Type"] = "application/json;charset=UTF-8"
	//
	//client := resty.New()
	//resp, ordinaryOrderErr := client.R().EnableTrace().
	//	SetCookie(ssoCookie).
	//	SetHeaders(headers).SetBody(order).
	//	Post(host + uri)
	//
	//if ordinaryOrderErr != nil {
	//	return "", ordinaryOrderErr
	//}
	//
	//return resp.String(), nil
}